package com.sdcs.ui;

import java.util.HashMap; 

import com.sdcs.R;
import com.sdcs.api.HttpApiAccessor;
import com.sdcs.util.Constants;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast; 



public class AnswerActivity extends Activity {
	private int course_id ;
	private  TextView tv_content ; 

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.discuss);

		course_id =  getIntent().getExtras().getInt("course_id") ;
        tv_content = (TextView) findViewById(R.id.content) ;
        
        Button btn_send = (Button) this.findViewById(R.id.send);
		btn_send.setOnClickListener( new View.OnClickListener() {
			
			public void onClick(View v) {
				 HashMap  map  = new HashMap() ;

				 map.put("news_id", String.valueOf(course_id)) ;
				 map.put("content", tv_content.getText().toString() ) ;
				 map.put("answer", "" ) ;
				 map.put("student_id", String.valueOf(Constants.student.getStudent_id()));
				 map.put("student_name", Constants.student.getStudent_name()) ;
				 
				 String result =  HttpApiAccessor.sendDiscuss(map) ;
				 if( result != null && result.equals("1") ){
					 Toast.makeText(AnswerActivity.this, "评论成功" , Toast.LENGTH_SHORT).show() ;
				 }
				finish();
			}
		}) ; 
 
    }
    
    
	 
	
    
}
